#include "inc.h"

#include "sockop.h"

#define TEST_PATH "/tmp/.usock"

sockop_ctx_t g_ctx;

int callback(char *line, int size, void *output, void *arg)
{
    (void)line;
    (void)size;
    (void)arg;
    printf("hello world\n");
    sockop_output(output, "hello world\n", 12);
    return 0;
}

void usock_init(void)
{
    if (sockop_usock_tostruct(TEST_PATH, &g_ctx.sun) < 0)
    {
        exit(-1);
    }

    unlink(TEST_PATH);

    g_ctx.type = SOCK_TYPE_UNIX;
    g_ctx.cache_size = 1024*1024;
    g_ctx.cb = callback;
}

int main(int argc, char *argv[])
{
    (void)argc;
    (void)argv;

    usock_init();

    if (sockop_server_run(&g_ctx) < 0)
    {
        return -1;
    }

    sockop_server_exit();

    return 0;
}

